/**
 * This is my code.
 *
 * $Id$
 */
package fi.jab.esb.config.xml.impl;

import fi.jab.esb.config.xml.ActionType;
import fi.jab.esb.config.xml.ActionsType;
import fi.jab.esb.config.xml.MepType;
import fi.jab.esb.config.xml.XmlPackage;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Actions Type</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link fi.jab.esb.config.xml.impl.ActionsTypeImpl#getAction <em>Action</em>}</li>
 *   <li>{@link fi.jab.esb.config.xml.impl.ActionsTypeImpl#getMep <em>Mep</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ActionsTypeImpl extends EObjectImpl implements ActionsType
{
  /**
   * The cached value of the '{@link #getAction() <em>Action</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getAction()
   * @generated
   * @ordered
   */
  protected EList<ActionType> action;

  /**
   * The default value of the '{@link #getMep() <em>Mep</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getMep()
   * @generated
   * @ordered
   */
  protected static final MepType MEP_EDEFAULT = MepType.REQUEST_RESPONSE;

  /**
   * The cached value of the '{@link #getMep() <em>Mep</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getMep()
   * @generated
   * @ordered
   */
  protected MepType mep = MEP_EDEFAULT;

  /**
   * This is true if the Mep attribute has been set.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   * @ordered
   */
  protected boolean mepESet;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected ActionsTypeImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return XmlPackage.Literals.ACTIONS_TYPE;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<ActionType> getAction()
  {
    if (action == null)
    {
      action = new EObjectContainmentEList<ActionType>(ActionType.class, this, XmlPackage.ACTIONS_TYPE__ACTION);
    }
    return action;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public MepType getMep()
  {
    return mep;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setMep(MepType newMep)
  {
    MepType oldMep = mep;
    mep = newMep == null ? MEP_EDEFAULT : newMep;
    boolean oldMepESet = mepESet;
    mepESet = true;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, XmlPackage.ACTIONS_TYPE__MEP, oldMep, mep, !oldMepESet));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void unsetMep()
  {
    MepType oldMep = mep;
    boolean oldMepESet = mepESet;
    mep = MEP_EDEFAULT;
    mepESet = false;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.UNSET, XmlPackage.ACTIONS_TYPE__MEP, oldMep, MEP_EDEFAULT, oldMepESet));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public boolean isSetMep()
  {
    return mepESet;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case XmlPackage.ACTIONS_TYPE__ACTION:
        return ((InternalEList<?>)getAction()).basicRemove(otherEnd, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case XmlPackage.ACTIONS_TYPE__ACTION:
        return getAction();
      case XmlPackage.ACTIONS_TYPE__MEP:
        return getMep();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case XmlPackage.ACTIONS_TYPE__ACTION:
        getAction().clear();
        getAction().addAll((Collection<? extends ActionType>)newValue);
        return;
      case XmlPackage.ACTIONS_TYPE__MEP:
        setMep((MepType)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case XmlPackage.ACTIONS_TYPE__ACTION:
        getAction().clear();
        return;
      case XmlPackage.ACTIONS_TYPE__MEP:
        unsetMep();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case XmlPackage.ACTIONS_TYPE__ACTION:
        return action != null && !action.isEmpty();
      case XmlPackage.ACTIONS_TYPE__MEP:
        return isSetMep();
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (mep: ");
    if (mepESet) result.append(mep); else result.append("<unset>");
    result.append(')');
    return result.toString();
  }

} //ActionsTypeImpl
